# # 打印菱形
# def print_diamond(n):
#     for i in range(n):  # 上半部分
#         for j in range(n - i - 1):
#             print(" ", end="")
#         for j in range(2 * i + 1):
#             print("*", end="")
#         print()
#     for i in range(n - 2, -1, -1):  # 下半部分
#         for j in range(n - i - 1):
#             print(" ", end="")
#         for j in range(2 * i + 1):
#             print("*", end="")
#         print()
#
#
# # 将输入转换为整数
# num = int(input("请输入一个数字: "))
# print_diamond(num)
#
#
# # 打印水仙花数
# def is_armstrong(num):
#     num_str = str(num)
#     num_digits = len(num_str)
#     sum_of_digits = sum(int(digit) ** num_digits for digit in num_str)
#     return num == sum_of_digits
#
#
# # 遍历所有三位数，找出水仙花数
# for num in range(100, 1000):
#     if is_armstrong(num):
#         print(num)
#
# # 打印九九乘法表
# for i in range(1, 10):
#     for j in range(1, i + 1):
#         print("%d*%d=%d" % (j, i, i * j), end=" ")
#     print()
#
#
# # 打印完数
# def is_perfect_number(num):
#     if num < 1:
#         return False
#     divisors_sum = 0
#     for i in range(1, num):
#         if num % i == 0:
#             divisors_sum += i
#     return divisors_sum == num
#
#
# # 打印一定范围内的所有完数
# def print_perfect_numbers(start, end):
#     for num in range(start, end + 1):
#         if is_perfect_number(num):
#             print(num)
#
#
# # 打印1到10000之间的所有完数
# print_perfect_numbers(1, 10000)
#
#
# # 打印质数
# def is_prime(num):
#     if num < 2:
#         return False
#     for i in range(2, int(num ** 0.5) + 1):
#         if num % i == 0:
#             return False
#     return True
#
#
# # 打印一定范围内的所有质数
# def print_primes(start, end):
#     for num in range(start, end + 1):
#         if is_prime(num):
#             print(num)
#
#
# # 打印1到100之间的所有质数
# print_primes(1, 100)
#
#
# # 打印斐波那契数列
# def fibonacci(n):
#     # 生成斐波那契数列的前 n 个数字
#     fib_sequence = [0, 1]
#     while len(fib_sequence) < n:
#         next_fib = fib_sequence[-1] + fib_sequence[-2]
#         fib_sequence.append(next_fib)
#     return fib_sequence
#
#
# # 设置需要打印的斐波那契数列长度
# def fibonacci(n):
#     # 生成斐波那契数列的前 n 个数字
#     fib_sequence = [0, 1]
#     while len(fib_sequence) < n:
#         next_fib = fib_sequence[-1] + fib_sequence[-2]
#         fib_sequence.append(next_fib)
#     return fib_sequence
#
#
# # 设置需要打印的斐波那契数列长度
# n = 10
# fib_sequence = fibonacci(n)
# print("斐波那契数列的前 {} 个数字为: {}".format(n, fib_sequence))

# 打印九九乘法表
# for i in range(1, 10):
#     for j in range(1, i + 1):
#         print("%d*%d=%d" % (j, i, i * j), end=" ")
#     print()
#
# # 打印水仙花数1000
# for i in range(100, 1000):
#     a = i % 10
#     b = i // 10 % 10
#     c = i // 100
#     if a ** 3 + b ** 3 + c ** 3 == i:
#         print(i)

# # 循环输出1到100之间的完数  range():含头不含尾
# for i in range(1,100):
#     sum = 0
#     for j in range(1,i):
#         if i % j == 0:
#             sum += j
#     if sum == i:
#         print(i,end=" ")
#
# # 求100以内的质数
# i = 2
# for j in range(1, 101):
#     if (j % i == 0):
#         continue
#     print(j)

# #打印星号
# hang = 9
# for i in range(1,2*((hang-1)//2+1),2):
#     print(("*" * i).center(hang))
# for i in range(2*((hang-1)//2)-1,0,-2):
#     print(("*" * i).center(hang))

# # 斐波那契数列前50个
# a,b=0,1
# for i in range(50):
#     print(a,end="\n")
#     a,b=b,a+b






